package com.yn.bsc.web.api;
import com.yn.bsc.core.Result;
import com.yn.bsc.core.ResultGenerator;
import com.yn.bsc.model.SiteHealthyDailyRecord;
import com.yn.bsc.model.SiteStations;
import com.yn.bsc.service.GeometryDictionaryService;
import com.yn.bsc.service.SiteHealthyDailyRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example.Criteria;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by ZuoLG on 2017/10/31.
*/
@RestController
@RequestMapping("/api/site/healthy/daily/record")
public class SiteHealthyDailyRecordController extends BaseController<SiteHealthyDailyRecordService, SiteHealthyDailyRecord>  {
    @Resource
    private SiteHealthyDailyRecordService siteHealthyDailyRecordService;
    @Resource
    private GeometryDictionaryService geometryDictionaryService;

    @PostMapping("/siteLevel")
    public Result siteLevel(@RequestParam String start,@RequestParam String end) {
        Map<String,Map<String,String>> siteLevels = new HashMap<>();
        List<String> areaList = geometryDictionaryService.findAllAreas();
        if (CollectionUtils.isEmpty(areaList)){
            return ResultGenerator.genSuccessResult(siteLevels);
        }

        for (String area : areaList){
            Map<String,String> levels = siteHealthyDailyRecordService.findSiteLevel(area,start,end);
            siteLevels.put(area,levels);
        }
        return ResultGenerator.genSuccessResult(siteLevels);
    }
}
